home *** CD-ROM | disk | FTP | other *** search
- ü
- Programming Routine
- ~~~~~~~~~~~~~~~~~~~
- ý
- Cross-style VUMeter Graphic Equalizer
-
- þ
- Written by Andrew "Mushroom" Kellett
-
- ù
- This is a routine that I developed a few weeks ago, whilst working
- on a demo to show the powers of AMOS, featuring lot's of VU power,
- vectors, bullballs, and much much more, all done using simple AMOS
- commands.
-
- I created this procedure, to emulate all kinds of different kinds
- of shapes, including a nice circle effect, similar to the one in the
- "Jesus on E's" demo, which inspired me to try and copy the effect. I
- am including the routine, as a few people have asked how it was
- actually done.
-
- The program requires one picture bank, which is the file called
- VU_CROSS, which is stored in the DATA drawer of the first disk. You
- may need to decrunch the file, depending on how much space I have
- ÿ
- ù
- available, and if I had to crunch it down. If you don't have a copy of
- Crunchmania, then you can use the RTDD program in the C: drawer of
- disk one, load in the bank to AMOS, and then re-save it as an
- uncrunched file. RTDD is a run-time decruncher, and requires the
- CRM.LIBRARY file to run, which is in the LIBS: drawer of disk 1.
-
- The FULL AMOS program, is situated on disk 2. The program is
- freely useable, as long as I get a mention in the credits somewhere if
- you copy the routine. Now, onto the description on how the listing
- actually operates.
-
- û
- Dim P(31)
- Global SETTING,P()
-
- F$=Fsel$("","","Select a Pro/Sound/Noise","Tracker module to use")
-
- Hide On
- If F$="" : Edit : End If
-
-
- ÿ
- û
- If Exist(F$)
- Track Load F$,3 : Track Play 3
- Track Loop On : Led Off
- Else
- Edit
- End If
-
- Proc PREPARE
-
- ù
- Sets up the initialization of the program. The screen used requires
- one array, which holds all the colours of the screen. SETTING is a
- number which can be assigned, and the routine quits out after that
- number of updates. If there is no information to be displayed
- on-screen, then the setting reaches it's target faster.
-
- The program then asks for you to give it a music module, in the form
- of either a Sound/Pro/Noisetracker module. This is then started to
- play, to make the VUMeter command start registering. Proc PREPARE is
- then called to initiate the screen.
-
- ÿ
- û
- Do
- Proc _VU5[200]
- Loop
-
- ù
- This part of the program is the bit which does all the main work. It
- will access the routine for 200 loops, before quitting out. I have set
- the delay to a short one, as you will have seen in the demo, with the
- changing colours. See the _VU5 routine for more details.
-
- û
- Procedure PREPARE
- Unpack 8 To 0 : Screen Hide 0 : For N=0 To 31 : Colour N,0 :
- Next N
- End Proc
-
- ù
- The program automatically presumes that bank 8 contains the picture of
- the cross. All the colours are then cleared from the screen, to begin
- the routine to draw the picture back in a special way. If you want to
- save on a bit of memory, then an ERASE 8 can be used after the UNPACK
- command.
-
- ÿ
- û
- Procedure _VU5[SETTING]
- TLP=0
- G=Rnd(3)
-
- If G=0
- DAT2:
- Data $0,$FFF,$EEE,$DDD,$CCC,$BBB,$AAA,$999,$FFF,$EEE,$DDD,$CCC
- Data $BBB,$AAA,$999,$999,$888,$666,$555,$444,$222,$333,$999
- Data $888,$777,$666,$555,$444,$333,$58C,$BB0,$99F
- Restore DAT2 : For OO=0 To 31 : Read P(OO) : Next OO
- End If
-
- If G=1
- DAT3:
- Data $0,$49,$3A,$3B,$2C,$1D,$1E,$F,$FFF,$EEE,$DDD,$CCC,$BBB
- Data $AAA,$999,$999,$888,$666,$555,$444,$222,$333,$900,$A00
- Data $B00,$C00,$D00,$E00,$F00,$58C,$BB0,$99F
- Restore DAT3 : For OO=0 To 31 : Read P(OO) : Next OO
- End If
-
- ÿ
- û
- If G=2
- DAT4:
- Data $0,$999,$888,$777,$666,$555,$444,$333,$999,$888,$777,$666
- Data $555,$444,$333,$999,$888,$777,$666,$555,$444,$333,$999
- Data $888,$777,$666,$555,$444,$333,$58C,$BB0,$99F
- Restore DAT4 : For OO=0 To 31 : Read P(OO) : Next OO
- End If
-
- If G=3
- DAT5:
- Data $0,$900,$A00,$B00,$C00,$D00,$E00,$F00,$90,$A0,$B0,$C0
- Data $D0,$E0,$F0,$990,$AA0,$BB0,$CC0,$DD0,$EE0,$FF0,$49,$3A
- Data $3B,$2C,$1D,$1E,$F,$58C,$BB0,$99F
- Restore DAT5 : For OO=0 To 31 : Read P(OO) : Next OO
- End If
-
- For N=0 To 31 : Colour N,0 : Next N
- Wait Vbl : Screen To Front 0 : Screen Show 0
-
- ù
- When the routine is first called, the program decides on a random
- ÿ
- ù
- colour in which to use. If you saw the routine running before you read
- this file, you would notice the equalizer "Appear" to be changing
- colours. This is all done randomly, and the computer decides on a
- number from 0-3 and changes the palette array accordingly. The screen
- is then cleared of all colours, and brings it into view in case any
- other routine has caused the screen to be hid.
-
- û
- Do
- Gosub ACQUIRE
- If TLP=>SETTING*2 : Exit : End If
- Inc TLP
- Loop
-
- ù
- This is the main loop inside the routine. It is constantly calling the
- routine ACQUIRE, which draws the current VU settings on the screen.
- The variable TLP is increased, until it is doubled the value assigned,
- then the program exits the loop, and calls a POP PROC, which exits it
- out of the procedure.
-
- û
- Pop Proc
- ÿ
-
- û
- ACQUIRE:
- A=(Vumeter(0))+1 : CH1=0 : B=(Vumeter(1))+1 : CH2=0
- C=(Vumeter(2))+1 : CH3=0 : D=(Vumeter(3))+1 : CH4=0
-
- ù
- A, B, C, and D are the numbers recieved from the VUmeter channels at
- the time of reading, and will range from the value of 0 - 63.
-
- û
- If A>A1 Then A1=A
- If A>A1 Then CH1=1
- If B>B1 Then B1=B
- If B>B1 Then CH2=1
- If C>C1 Then C1=C
- If C>C1 Then CH3=1
- If D>D1 Then D1=D
- If D>D1 Then CH4=1
-
- ù
- If the values read are higher than the ones which are in memory, then
- they are loaded with the appropriate figures. If the number is lower,
- then nothing is changed.
- ÿ
-
- û
- If CH1=0 Then A1=A1-1
- If CH2=0 Then B1=B1-1
- If CH3=0 Then C1=C1-1
- If CH4=0 Then D1=D1-1
-
- ù
- If no numbers were added to any of the channels in memory, then the
- CH1 - 4 will be 0, and this deducts 1 from the memory value on the
- channels which did not have any increases to them. This gives the
- on-screen effect of the equalizer dropping down slowly if there is no
- action there.
-
- û
- If A1<0 Then A1=0
- If B1<0 Then B1=0
- If C1<0 Then C1=0
- If D1<0 Then D1=0
-
- ù
- If any of the channels drops below 0 for some reason, then this piece
- of the program will take it back to 0 to make the program work
- correctly, especially if it is looking for a value of 0.
- ÿ
- û
-
- P=A1/10 : If A1=>62 : P=7 : End If : Gosub _DRAW1
- P=B1/10 : If B1=>62 : P=7 : End If : Gosub _DRAW2
- P=C1/10 : If C1=>62 : P=7 : End If : Gosub _DRAW3
- P=D1/10 : If D1=>62 : P=7 : End If : Gosub _DRAW4
- Return
-
- ù
- Now, the program calls a draw routine for each of the four channels.
- The value of P is assigned a variable of 0 - 5, or is assigned to 7 if
- the VUmeter reading is at it's maximum. Looking at the draw routines
- below, you will see why I have had to use 1-7. Although you will set
- the value to 7, you may not actually see the effect on-screen, as the
- updates are made so quickly, especially when it has been compiled.
-
- û
- _DRAW1:
- If P=0 : Colour 1,0 : End If
- If P>0
- For N=1 To P : Colour N,P(N) : Next N
- If P<7 : For N=P+1 To 7 : Colour N,0 : Next N : End If
- End If
- ÿ
- û
- Return
-
- _DRAW2:
- If P=0 : Colour 8,0 : End If
- If P>0
- For N=1 To P : Colour N+7,P(N+7) : Next N
- If P<7 : For N=7+(P+1) To 13 : Colour N,0 : Next N : End If
- End If
- Return
-
- _DRAW3:
- If P=0 : Colour 15,0 : End If
- If P>0
- For N=1 To P : Colour N+14,P(N+14) : Next N
- If P<7 : For N=14+(P+1) To 20 : Colour N,0 : Next N : End If
- End If
- Return
-
- _DRAW4:
- If P=0 : Colour 22,0 : End If
- ÿ
- û
- If P>0
- For N=1 To P : Colour N+21,P(N+21) : Next N
- If P<7 : For N=21+(P+1) To 27 : Colour N,0 : Next N : End If
- End If
- Return
- End Proc
-
- ù
- These are the 4 draw routines, seperated into individual routines to
- make it easier for you to follow. The program looks at the number in
- P, and assigns the first P of 6 colours with the correct value, for
- the appropriate character. If the number in P is less than 6, then the
- rest are filled with 0, to clear any unwanted debris off the screen.
- Each bar has 7 colours to use, as I decided to use a 32 colour screen.
- Any bigger, and the effects would have started getting slower, however
- a HAM screen compiled, would not be a bad idea. Maybe I will get to
- that.
-
-
-
-
- ÿ
- þ
- Well, there you have it. A fully-functional VU cross demo. If you
- are having problems with this routine, then why not drop me a line at
- the Mushroom PD address, or give me a call. The address is scattered
- around various different parts of the magazine.
-
- ú
- If you have any excellent routines which you would like to
- include, then why not send me the AMOS listing, and a documented
- procedure breakdown, like this, and I will include it. Remember, you
- will receive a FREE copy of the first issue your article appears in.
-
- ý
- All mail sent to me will be replied to as soon as possible,
- depending on how busy I am. If you are sending disks, then why not
- fill them with your AMOS programs and PD so I can include them in the
- library. The address is scattered around various articles.
-
- ÷
- EOF
-
-